package com.xbongbong.paas.pojo.dto;

import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.xbongbong.paas.domain.entity.PaasFormDataEntity;
import com.xbongbong.paas.field.FieldAttrEntity;
import com.xbongbong.paas.toolbox.wrap.BaseDTO;
import com.xbongbong.paas.toolbox.wrap.QueryIgnore;
import com.xbongbong.pro.formdata.pojo.SaasNeedRedundantAttrPojo;
import com.xbongbong.pro.product.pojo.vo.ChildProductVO;
import com.xbongbong.pro.user.pojo.ReturnUserAndDepartmentPojo;
import com.xbongbong.saas.domain.entity.DistributorBaseInfoEntity;
import com.xbongbong.saas.domain.entity.OnlinePaymentFlowEntity;
import com.xbongbong.saas.domain.entity.WorkOrderEntity;
import com.xbongbong.sys.domain.entity.UserEntity;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;

import java.util.List;
import java.util.Map;
import java.util.Objects;


/**
 * @author haibing.zhang
 * @version 1.0
 *  * @date 2019/1/16
 *  * @since v1.0v
 */
@Setter
@Getter
@ToString
public class SaasFormSaveDTO extends BaseDTO {
    private static final long serialVersionUID = -6746420175810812560L;
    /**
     * 是否新建
     */
    private Boolean isNew;
    /**
     * 新实体
     */
    private PaasFormDataEntity newPaasFormDataEntity;
    /**
     * 旧实体
     */
    private PaasFormDataEntity oldPaasFormDataEntity;
    /**
     * 新数据
     */
    private JSONObject newData;
    /**
     * 旧数据
     */
    private JSONObject oldData;
    /**
     *
     */
    private Integer businessType;
    /**
     *
     */
    private Integer subBusinessType;
    /**
     * saas所需的特殊传参pojo
     */
    private SaasNeedRedundantAttrPojo saasNeedRedundantAttrPoJo;

    /**
     * 工单模板id
     */
    // TODO: 2019/3/28 去掉
    private Long templateId;

    /**
     * 工单实体
     */
    private WorkOrderEntity newWorkOrderEntity;
    /**
     * 工单旧实体
     */
    private WorkOrderEntity oldWorkOrderEntity;
    /**
     * 是否是导入
     */
    @Getter(onMethod_ = {@QueryIgnore})
    private Integer isImport;
    /**
     * 负责人
     */
    private List<ReturnUserAndDepartmentPojo> ownerId;
    /**
     * 协同人
     */
    private List<ReturnUserAndDepartmentPojo> coUserId;
    /**
     * 可见部门集合
     */
    private List<Object> visbleDept;
    /**
     * 可见人集合
     */
    private List<Object> visbleUser;
    /**
     * 流程创建人id
     */
    private String processCreatorId;
    /**
     * useMap
     */
    private Map<String, UserEntity> useMap;
    /**
     * 字段容器
     */
    private Map<String, FieldAttrEntity> explainMap;
    /**
     * 金额明细相关
     */
    private JSONArray amountDetail;
    /**
     * childProductVO 子产品
     */
    private ChildProductVO childProductVO;

    /**
     * 产品成本相关
     */
    private Map<Object, Double> costMap;

    private Integer hasReceivables;
    // ===============================
    /**
     * 线索转换客户操作，下面的是否要将销售线索的跟进记录自动带入客户按钮
     */
    private Integer isBringCustomer;
    private Long clueId;
    // ===============================
    /**
     * 是否外链新建
     */
    private Integer fromOuterLink;

    /**
     * 是否来自审批 1表示来自审批
     */
    private Integer isFromProcess;

    /**
     * 在线支付流水信息
     */
    private OnlinePaymentFlowEntity onlinePaymentFlowEntity;

    /**
     * 主键id
     */
    private Long dataId;

    private Long refundId;

    private Long returnedPurchaseId;

    /**
     * 经销商基础信息信息
     */
    private DistributorBaseInfoEntity distributorBaseInfoEntity;

    // 流程类型
    private Integer taskType;

    //审批提交人id
    private String commitUserId;

    public Boolean getIsNew() {
        return Objects.nonNull(isNew) && isNew;
    }
}
